var PaymentTardinessInfo = function (finance) {
  BaseModel.call(this);

  var self = this;
  var fn = {
    initData: function (finance) { //客户型号
      var fields = ['companyOrderId', 'factoryNo', 'customerNo', 'customerName', 'materialName', 'providerName', 'model', 'color', 'oweMoney',
        'inOutMoney', 'receiptPaymentPrice'
      ];
      self.setDataFromObj(finance, fields);

      var payTime = finance.payTime;
      self.payTime = moment(payTime).valueOf();

      self.id = SysUtil.getId();
    }
  };

  fn.initData(finance);
};

var PaymentTardinessConfigModel = function (hideColumns) {
  BaseModel.call(this);

  var self = this;
  var fn = {
    initData: function (hideColumns) {
      hideColumns = _.cloneDeep(hideColumns);
      self.hideColumns = hideColumns;

      var tableFields = PaymentTardinessConfigModel.tableFields;
      var fieldList = [];
      for (var i = 0; i < tableFields.length; i++) {
        var tableField = tableFields[i];
        var id = tableField.id;
        var checked = hideColumns.indexOf(id) === -1;
        fieldList.push({
          id: id,
          label: tableField.label,
          checked: checked
        });
      }
      self.fieldList = fieldList;
    }
  };

  this.getHideColumns = function () {
    var fieldList = this.fieldList;
    var hideFieldList = _.filter(fieldList, {
      checked: false
    });
    if (fieldList.length === hideFieldList.length) {
      return null;
    }
    return _.map(hideFieldList, 'id');
  };

  fn.initData(hideColumns);
};

PaymentTardinessConfigModel.tableFields = [{
  id: "companyOrderId",
  label: "订单编号"
}, {
  id: "factoryNo",
  label: "工厂型号"
}, {
  id: "customerNo",
  label: "客户型号"
}, {
  id: "customerName",
  label: "客户名称"
}, {
  id: "materialName",
  label: "物料名称"
}, {
  id: "providerName",
  label: "供应商"
}, {
  id: "color",
  label: "编号"
}, {
  id: "model",
  label: "规格型号"
}, {
  id: "payTime",
  label: "应付时间"
}, {
  id: "inOutMoney",
  label: "应付金额"
}, {
  id: "receiptPaymentPrice",
  label: "实付金额"
}, {
  id: "oweMoney",
  label: "欠额"
}];
